package com.kancy.vip.util;

import java.lang.reflect.Constructor;

public class ReflectUtil {

    public static <T> T getObject(Class<T> clazz){
        if(clazz == null){
            return null;
        }
        try {
            Constructor constructor = clazz.getDeclaredConstructor(null);
            constructor.setAccessible(true);
            Object instance = constructor.newInstance();
            return (T)instance;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static Object getObject(String className){
        try {
            Object object = getObject(Class.forName(className));
            return object;
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }
}
